<?php
if(is_plugin_page()) {
    load_plugin_textdomain('hidepost', 'wp-content/plugins/hidepost');
    $location = get_option('siteurl') . '/wp-admin/admin.php?page=hidepost/options.php';
	
//Update Option
if ('process' == $_POST['stage']) {
        update_option('content_text', trim($_POST['content_text']));
		update_option('link_text', trim($_POST['link_text']));
		update_option('hide_link', $_POST['hide_link']);
		update_option('allow_bot', $_POST['allow_bot']);
		update_option('hide_content', $_POST['hide_content']);
    }


//Load the config
include("option_init.php");
function the_view($special_var){
	return htmlspecialchars(stripslashes($special_var));
}
//Main Option Page
?>
<form name="update_hidepost" method="post" action="<?php echo $location ?>&amp;updated=true">
<input type="hidden" name="stage" value="process" /> 
	<div class="wrap">
		<h2>HidePost Options</h2>
		<p>
			<?php 
				if ($hide_content!=1){$checked="";} else {$checked="checked";}
			?>
			<input name="hide_content" type="checkbox" id="hide_content" value="1" <?php echo $checked; ?>/>
			<label><strong>Enable Hidepost</strong> (Uncheck if you want to disable HidePost).</label>
		</p>
		<p>
			<?php 
				if ($hide_link!=1){$checked="";} else {$checked="checked";}
			?>
			<input name="hide_link" type="checkbox" id="hide_link" value="1" <?php echo $checked; ?>/>
			<label><strong>Protect Link</strong> (Only logged in member can see link on your post).</label>
		</p>
		<p>
			<?php 
				if ($allow_bot!=1){$checked="";} else {$checked="checked";}
			?>
			<input name="allow_bot" type="checkbox" id="allow_bot" value="1" <?php echo $checked; ?>/>
			<label><strong>Allow bot</strong> (This will allow Bot engine like Google and Yahoo can access your protected content).</label>
		</p>
		<p>	
			<label><font size=3>Protect content show text:  </font></label> 
		</p>
		<p>	
			<span>&nbsp;&nbsp;</span>
			<input name="content_text" type="text" id="content_text" value="<?php echo the_view($content_text); ?>" size="100" />	
		</p>
		<p>	
			<label><font size=3>Protect link show text:  </font></label>
		</p>
		<p>
			<span>&nbsp;&nbsp;</span>
			<input name="link_text" type="text" id="link_text" value="<?php echo the_view($link_text); ?>" size="100" />
		</p>
		<p><strong>Note: </strong></p>
		<p>%login% = Link to you Login page.</p>
		<p>		 %register% = Link to you Register page.</p>
		<p>		 You can only use some simple HTML code in the show text.</p>
		<p><strong>UserLevel</strong></p>
		<p>You can use [hidepost=level][/hidepost] where level = 0->9</p>
		<p>0 = Registered Member</p>
		<p>....</p>
		<p>9 = Administrator</p>
		<p>More help can be found on http://codex.wordpress.org/User_Levels</p>
		<p class="submit">
            <input type="submit" name="Submit" value="Save Options  &raquo;" />
        </p>
	</div>
</form>
<?php
}
?>
